package com.toolsder.demo.spring.security.jwt.config.handler;

import com.toolsder.demo.spring.security.jwt.entity.JsonResult;
import com.toolsder.demo.spring.security.jwt.exception.DefinedException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * created by 猴子请来的逗比 On 2020/8/27
 * <p>
 * 全局异常处理
 *
 * @author by 猴子请来的逗比
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    @ExceptionHandler(value = DefinedException.class)
    @ResponseBody
    public JsonResult<String> userDefinedExceptionHandler(DefinedException e) {
        return JsonResult.error(e.getMessage());
    }

}
